<template>
  <div id="el_select">
    <img :src="src" v-if="src" />
    <span>{{ title }}</span>
    <el-select
      v-model="now_value"
      @change="change"
      :popper-class="class_name"
      placeholder="请选择"
    >
      <el-option v-for="item in options" :key="item" :value="item"> </el-option>
    </el-select>
  </div>
</template>

<script>
export default {
  name: "el_select",
  components: {},
  data() {
    return {
      now_value: this.value,
    };
  },
  model: {
    prop: "value",
    event: "returnBack",
  },
  props: ["value", "options", "src", "title", "class_name"],

  created: function () {
    this.$watch("value", function (newValue, oldValue) {
      this.now_value = this.value;
    });
  },
  mounted() {},
  methods: {
    change() {
      this.$emit("returnBack", this.now_value);
    },
  },
};
</script>
<style scoped lang='less'>
#el_select {
  > span {
    font-size: 14px;
    font-weight: normal;
    font-stretch: normal;
    letter-spacing: 0px;
    white-space: nowrap;
    margin-right: 16px;
    color: #555;
  }
  > img {
    width: 16px;
    margin-right: 10px;
  }
  display: flex;
  width: fit-content;
  align-items: center;
}
</style>
